home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Other Stuff / Demos ƒ / Demo AppMaker / Demo AppMaker™ / Demo AppMaker™.rsrc / TmCT_303_zDoc < prev    next >
Encoding:
Text File  |  1990-03-23  |  3.9 KB  |  181 lines

  1. /* %filename% -- document methods */
  2. /* Created %date% %time% by AppMaker */
  3.  
  4. /*    We recommend that you not modify this module and instead modify        */
  5. /*    its subclass, %Appname%Doc.  The 'z' prefix on this module marks%    %*/
  6. /*    a module which is likely to be regenerated by AppMaker after you    */
  7. /*    make changes to the user interface.  The modules without the 'z'    */
  8. /*    prefix will not be regenerated by AppMaker unless you delete them.    */
  9. /*    Using a separate subclass to override the AppMaker-generated code    */
  10. /*    lets you regenerate code without losing your hand-coded changes.    */ 
  11.  
  12. #include <Commands.h>
  13. #include <Global.h>
  14. #include <CApplication.h>
  15. #include <CBartender.h>
  16. #include <CDataFile.h>
  17. #include <CDecorator.h>
  18. #include <CDesktop.h>
  19. #include <CError.h>
  20. #include <TBUtilities.h>
  21. %for each window gen include%
  22. #include "z%Appname%Doc.h"
  23.  
  24. extern    CApplication    *gApplication;    /* The application */
  25. extern    CBartender        *gBartender;    /* The menu handling object */
  26. extern    CDecorator        *gDecorator;    /* Window dressing object */
  27. extern    CBureaucrat        *gGopher;        /* The current boss in the chain of command */
  28. extern    CError            *gError;        /* The error handling object */
  29. extern    OSType             gSignature;    /* The application's signature */
  30.  
  31. /*----------*/
  32. void    Z%Appname%Doc::I%Appname%Doc    (
  33.                          CBureaucrat    *aSupervisor,
  34.                          Boolean        printable)
  35. {
  36.     CDocument::IDocument (aSupervisor, printable);
  37.     %for each window gen initNil%
  38.  
  39. } /* I%Appname%Doc */
  40.  
  41. %if multiWindow%
  42.     /*----------*/
  43.     void    Z%Appname%Doc::Dispose (void)
  44.     {
  45.         %for each window gen dispose%
  46.         itsWindow = NULL;
  47.         inherited::Dispose ();
  48.     } /* Dispose */
  49.     
  50.     /*----------*/
  51.     void    Z%Appname%Doc::ActivateWind (CWindow    *theWindow)
  52.     {
  53.         itsWindow = theWindow;
  54.         inherited::ActivateWind (theWindow);
  55.     } /* ActivateWind */
  56.     
  57.     /*----------*/
  58.     void    Z%Appname%Doc::DeactivateWind (CWindow    *theWindow)
  59.     {
  60.         itsWindow = theWindow;
  61.         inherited::DeactivateWind (theWindow);
  62.     } /* DeactivateWind */
  63.     
  64.     /*----------*/
  65.     void    Z%Appname%Doc::CloseWind (CWindow    *theWindow)
  66.     {
  67.         %for each window gen closeWind%
  68.         }
  69.     } /* CloseWind */
  70.  
  71. %endif%
  72. /*----------*/
  73. Boolean    Z%Appname%Doc::ReadData        (Handle        *theData)
  74. {
  75.     return (FALSE);
  76.  
  77. } /* ReadData */
  78.  
  79. /*----------*/
  80. void    Z%Appname%Doc::WriteData    (void)
  81. {
  82.     /* application-specific write data to itsFile */
  83. } /* WriteData */
  84.  
  85. /*----------*/
  86. void    Z%Appname%Doc::NewFile        (void)
  87. {
  88.     BuildWindows ();
  89.     itsWindow->Select ();
  90.  
  91. } /* NewFile */
  92.  
  93. /*----------*/
  94. void     Z%Appname%Doc::OpenFile        (SFReply    *macSFReply)
  95. {
  96.     CDataFile        *theFile;
  97.     Handle            theData;
  98.     Str63            theName;
  99.     OSErr            theError;
  100.  
  101.     theFile = new (CDataFile);
  102.     theFile->IDataFile ();
  103.     theFile->SFSpecify (macSFReply);
  104.     itsFile = theFile;
  105.     theError = theFile->Open (fsRdWrPerm);
  106.     if (!gError->CheckOSError (theError)) {
  107.         Dispose ();
  108.         return;
  109.     }
  110.  
  111.     if (!ReadData (&theData)) {
  112.         Dispose ();
  113.         return;
  114.     }
  115.  
  116.     BuildWindows ();
  117.     DisposHandle (theData);
  118.     itsFile->GetName (theName);
  119.     itsWindow->SetTitle (theName);
  120.     itsWindow->Select ();
  121.  
  122. } /* OpenFile */
  123.  
  124. /*----------*/
  125. void    Z%Appname%Doc::BuildWindows    (void)
  126. {
  127.     %for each window gen create%
  128. } /* BuildWindows */
  129.  
  130. /*----------*/
  131. Boolean    Z%Appname%Doc::DoSave        (void)
  132. {
  133.     if (itsFile == NULL) {
  134.         return (DoSaveFileAs ());
  135.     } else {
  136.         WriteData ();
  137.         dirty = FALSE;
  138.         gBartender->DisableCmd (cmdSave);
  139.         return (TRUE);
  140.     }
  141. } /* DoSave */
  142.  
  143. /*----------*/
  144. Boolean    Z%Appname%Doc::DoSaveAs        (SFReply    *macSFReply)
  145. {
  146.     CDataFile        *theFile;
  147.  
  148.     if (itsFile != NULL) {
  149.         itsFile->Dispose ();
  150.     }
  151.  
  152.     theFile = new (CDataFile);
  153.     theFile->IDataFile ();
  154.     theFile->SFSpecify (macSFReply);
  155.     itsFile = theFile;
  156.  
  157.     theFile->CreateNew (gSignature, 'TEXT');
  158.     theFile->Open (fsRdWrPerm);
  159.  
  160.     itsWindow->SetTitle (macSFReply->fName);
  161.  
  162.     return (DoSave ());
  163.  
  164. } /* DoSaveAs */
  165.  
  166. /*----------*/
  167. void Z%Appname%Doc::DoCommand (long        theCommand)
  168. {
  169.     switch (theCommand) {
  170.         case cmdClose:
  171.                 CloseWind (itsWindow);
  172.             break;
  173.         default:
  174.                 inherited::DoCommand (theCommand);
  175.             break;
  176.     } /* switch */
  177.  
  178. } /* DoCommand */
  179.  
  180. /* %filename% */
  181.